package com.jt.tenant.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.jt.tenant.R;
import com.jt.tenant.app.JTApplication;
import com.jt.tenant.conn.GetInsurerList;
import com.jt.tenant.conn.GetSpecialSaleList;

import java.util.List;

/**
 * Created by Administrator on 2016/4/7.
 */
public class InsurerListAdapter extends BaseAdapter {

    private Context context;

    private List<GetInsurerList.InsurerList> list;

    public InsurerListAdapter(Context context, List<GetInsurerList.InsurerList> list) {

        this.context = context;

        this.list = list;

    }

    @Override
    public int getCount() {

        return list.size();

    }

    @Override
    public Object getItem(int position) {

        return list.get(position);

    }

    @Override
    public long getItemId(int position) {

        return position;

    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;

        if (convertView == null) {

            convertView = View.inflate(context, R.layout.item_insurer_list, null);

            JTApplication.ScaleScreenHelper.loadView((ViewGroup) convertView);

            holder = new ViewHolder();

            holder.logo  = (ImageView) convertView.findViewById(R.id.iv_insurer_list_logo);

            holder.ad = (ImageView)convertView.findViewById(R.id.iv_insurer_list_ad);

            holder.describe = (TextView) convertView.findViewById(R.id.tv_insurer_list_des);



            convertView.setTag(holder);

        } else {

            holder = (ViewHolder) convertView.getTag();

        }

        JTApplication.UtilAsyncBitmap.get(list.get(position).LOGO, holder.logo,R.mipmap.loading);

        holder.describe.setText(list.get(position).DESCRIBE1);

        JTApplication.UtilAsyncBitmap.get(list.get(position).PIC, holder.ad,R.mipmap.loading);

        return convertView;

    }

    class ViewHolder {

        private ImageView logo;

        private ImageView ad;

        private TextView describe;



    }
}
